package com.unience.ec2.eclipse.dialog;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;

import com.xerox.amazonws.ec2.ImageDescription;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ImageDescriptionDialog extends org.eclipse.swt.widgets.Dialog {

	private Shell dialogShell;
	private ImageDescription imageDesc;
	private Text textId;
	private Text textLocation;
	private Label labelOwnerId;
	private Text textOwner;
	private Button buttonAccept;
	private Composite composite1;
	private Text textState;
	private Label label1;
	private Label labelLocation;
	private Label labelId;

	public ImageDescription getImageDesc() {
		return imageDesc;
	}

	public void setImageDesc(ImageDescription imageDesc) {
		this.imageDesc = imageDesc;
	}

	/**
	* Auto-generated main method to display this 
	* org.eclipse.swt.widgets.Dialog inside a new Shell.
	*/
	public static void main(String[] args) {
		try {
			Display display = Display.getDefault();
			Shell shell = new Shell(display);
			ImageDescriptionDialog inst = new ImageDescriptionDialog(shell, SWT.NULL);
			inst.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public ImageDescriptionDialog(Shell parent, int style) {
		super(parent, style);
	}

	public void open() {
		try {
			Shell parent = getParent();
			dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
			
			dialogShell.setText("Image Info " + imageDesc.getImageId() );
			
			GridLayout dialogShellLayout = new GridLayout();
			dialogShellLayout.numColumns = 2;
			dialogShell.setLayout(dialogShellLayout);
			dialogShell.layout();
			dialogShell.pack();			
			dialogShell.setSize(483, 197);
			{
				labelId = new Label(dialogShell, SWT.NONE);
				GridData labelIdLData = new GridData();
				labelIdLData.widthHint = 67;
				labelIdLData.heightHint = 17;
				labelId.setLayoutData(labelIdLData);
				labelId.setText("Id");
			}
			{
				GridData textIdLData = new GridData();
				textIdLData.widthHint = 352;
				textIdLData.heightHint = 17;
				textId = new Text(dialogShell, SWT.BORDER);
				textId.setLayoutData(textIdLData);
			}
			{
				labelLocation = new Label(dialogShell, SWT.NONE);
				labelLocation.setText("Location");
			}
			{
				textLocation = new Text(dialogShell, SWT.BORDER);
				GridData textLocationLData = new GridData();
				textLocationLData.widthHint = 347;
				textLocationLData.heightHint = 17;
				textLocation.setLayoutData(textLocationLData);
				textLocation.setText("text1");
			}
			{
				labelOwnerId = new Label(dialogShell, SWT.NONE);
				labelOwnerId.setText("Owner");
			}
			{
				GridData textOwnerLData = new GridData();
				textOwnerLData.widthHint = 346;
				textOwnerLData.heightHint = 17;
				textOwner = new Text(dialogShell, SWT.BORDER);
				textOwner.setLayoutData(textOwnerLData);
			}
			{
				label1 = new Label(dialogShell, SWT.NONE);
				GridData label1LData = new GridData();
				label1LData.widthHint = 58;
				label1LData.heightHint = 17;
				label1.setLayoutData(label1LData);
				label1.setText("State");
			}
			{
				GridData textStateLData = new GridData();
				textStateLData.widthHint = 346;
				textStateLData.heightHint = 17;
				textState = new Text(dialogShell, SWT.BORDER);
				textState.setLayoutData(textStateLData);
			}
			{
				composite1 = new Composite(dialogShell, SWT.NONE);
				GridLayout composite1Layout = new GridLayout();
				composite1Layout.makeColumnsEqualWidth = true;
				composite1.setLayout(composite1Layout);
			}
			{
				buttonAccept = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
				GridData buttonAcceptLData = new GridData();
				buttonAcceptLData.widthHint = 66;
				buttonAcceptLData.heightHint = 27;
				buttonAccept.setLayoutData(buttonAcceptLData);
				buttonAccept.setText("Accept");
				buttonAccept.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent event) {				    	
						dialogShell.close();
					}
				});
			}

			textId.setText(imageDesc.getImageId());
			textLocation.setText(imageDesc.getImageLocation());
			textOwner.setText(imageDesc.getImageOwnerId());
			textState.setText(imageDesc.getImageState());
			dialogShell.setLocation(getParent().toDisplay(100, 100));
			dialogShell.open();
			Display display = dialogShell.getDisplay();
			while (!dialogShell.isDisposed()) {
				if (!display.readAndDispatch())
					display.sleep();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
